package com.vhall.component.controller.interactive;

import com.vhall.component.controller.interactive.facade.QaApiFacade;
import com.vhall.component.entity.interactive.ListReqVo;
import com.vhall.component.entity.interactive.vo.CreateReqVo;
import com.vhall.component.entity.interactive.vo.QuestionRspVo;
import com.vhall.component.entity.interactive.vo.ToggleAlsoAskReqVo;
import com.vhall.component.framework.common.annotation.VhallComponent;
import com.vhall.component.plugin.common.annotation.ApiSignatureAuth;
import com.vhall.component.plugin.common.annotation.VssTokenAuth;
import com.vhall.component.plugin.common.support.VssToken;
import com.vhall.component.plugin.common.support.VssTokenThreadLocal;
import com.vhall.component.service.interactive.QaService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.Map;

/**
 * @author xianglei
 * @date 2021/7/15 16:17
 */
@ApiSignatureAuth
@VssTokenAuth
@VhallComponent
public class QaApiController implements QaApiFacade {

    @Autowired
    private QaService qaService;

    @Override
    public QuestionRspVo create(CreateReqVo reqVo) {
        VssToken token = VssTokenThreadLocal.getToken();
        reqVo.setAccountId(token.getThirdPartyUserId());
        return qaService.create(reqVo);
    }

    @Override
    public Map<String, Object> lists(ListReqVo reqVo) {
        VssToken token = VssTokenThreadLocal.getToken();
        reqVo.setAccountId(token.getThirdPartyUserId());
        return qaService.lists(reqVo);
    }

    @Override
    public QuestionRspVo toggleAlsoAsk(ToggleAlsoAskReqVo reqVo) {
        VssToken token = VssTokenThreadLocal.getToken();
        reqVo.setAccountId(token.getThirdPartyUserId());
        return qaService.toggleAlsoAsk(reqVo);
    }
}
